package co.edu.javeriana.konigsberg.xavier.servicio;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import javax.ejb.Stateful;
import javax.ejb.Stateless;

import co.edu.javeriana.konigsberg.xavier.dto.FestivoDTO;

@Stateless
public class FestivoServicio implements FestivoServicioLocal, FestivoServicioRemote{
	private static List<FestivoDTO> festivoDTOs;
	static{
		int mes[] = {0, 0,  2,  3, 3, 4, 4,  5, 5,  5,  6,  7, 7,  9, 10, 10, 11, 11};
		int dia[] = {1, 12, 23, 2, 3, 1, 18, 8, 15, 29, 20, 7, 17, 12, 2,  16, 8,  25};
		festivoDTOs = new ArrayList<FestivoDTO>();
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.MILLISECOND, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		
		FestivoDTO dto = null;
		for (int i = 0; i < dia.length ; i++) {
			calendar.set(Calendar.MILLISECOND, 0);
			calendar.set(Calendar.DAY_OF_MONTH, dia[i]);
			calendar.set(Calendar.MONTH, mes[i]);
			calendar.set(Calendar.YEAR, 2015);
			dto = new FestivoDTO();
			dto.setDiaFestivo(calendar.getTime());
			festivoDTOs.add(dto);
		}
	}
	@Override
	public List<FestivoDTO> obtenerLista() {
		return festivoDTOs;
	}
	public static void main(String a[]){
		FestivoServicio festivoServicio = new FestivoServicio();
		List<FestivoDTO> dtos = festivoServicio.obtenerLista();
		for (FestivoDTO festivoDTO : dtos) {
			System.out.println(festivoDTO.getDiaFestivo());
		}
	}
}
